/*
生成kafka消费方，从中取出对应topic的日志信息，转存到ES中
*/
package main

import (
	mainfuncs "LogManagementSystem/Logs_Transferto_ES/mainFuncs"
	"fmt"

	"github.com/astaxie/beego/logs"
)

func main() {

	err := mainfuncs.InitConfig("ini", "/Users/fcou/go/src/LogManagementSystem/Logs_Transferto_ES/conf/Logs_Transferto_ES.conf")
	if err != nil {
		panic(err)
		return
	}
	fmt.Println(mainfuncs.AppLogConfig)

	err = mainfuncs.InitLogger(mainfuncs.AppLogConfig.LogPath, mainfuncs.AppLogConfig.LogLevel)
	if err != nil {
		panic(err)
		return
	}
	logs.Debug("init logger succ")

	err = mainfuncs.InitKafka(mainfuncs.AppLogConfig.KafkaAddr, mainfuncs.AppLogConfig.KafkaTopic)
	if err != nil {
		logs.Error("init kafka failed, err:%v", err)
		return
	}
	logs.Debug("init kafka succ")

	err = mainfuncs.InitES(mainfuncs.AppLogConfig.ESAddr)
	if err != nil {
		logs.Error("init es failed, err:%v", err)
		return
	}
	logs.Debug("init es client succ")

	err = mainfuncs.Run()
	if err != nil {
		logs.Error("run  failed, err:%v", err)
		return
	}

	logs.Warn("warning, log_transfer is exited")

	mainfuncs.SendToWeixin() //立即微信通知：程序退出

}
